<html>
<head>
  <title>27-慢查询日志</title>
  <basefont face="微软雅黑" size="2" />
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
  <meta name="exporter-version" content="YXBJ Windows/600646 (zh-CN, DDL); Windows/6.1.1 (Win64);"/>
  <meta name="content-class" content="yinxiang.markdown"/>
  <style>
    body, td {
      font-family: 微软雅黑;
      font-size: 10pt;
    }
  </style>
</head>
<body>
<a name="1299"/>
<h1>27-慢查询日志</h1>

<div><span><div style="font-size: 14px; margin: 0; padding: 0; width: 100%;"><h2 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 34px; border-bottom: 1px solid #dbdbdb; color: #333;"></h2>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">慢查询日志由执行时间超过<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">long_query_time</strong>，并且扫面记录行数大于等于<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">min_examined_row_limit</strong>的SQL语句组成。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">慢查询日志可用于查找需要很长时间才能执行的查询，因此是优化的候选者。但是，检查慢查询日志可能是一项耗时的任务。为了简化这一过程，可以使用<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">mysqldumpslow</strong>命令处理慢速查询日志文件并汇总其内容。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">获取初始锁定的时间不计入执行时间。mysqld在执行完后以及释放所有锁之后向慢查询日志写入一个语句，因此日志顺序可能与执行顺序不同。</p>
<h2 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 34px; border-bottom: 1px solid #dbdbdb; color: #333;">慢查询日志参数</h2>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">slow_query_log</strong><br/>
默认情况下，禁用慢查询日志。要明确指定初始慢查询日志状态，0关闭，1开启。要指定日志文件名，使用<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">slow_query_log_file</strong>，要指定日志目标，使用<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">log_output</strong></p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">slow_query_log_file</strong><br/>
如果没有为慢查询日志文件指定名称，则默认名称为 host_name-slow.log。服务器在数据目录中创建文件，除非给出绝对路径名来指定不同的目录。</p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">long_query_time</strong><br/>
最小值为0，默认值为10，单位秒，范围：global、session</p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">log_slow_admin_statements</strong><br/>
默认情况下，不记录管理语句，也不记录不使用索引进行查找的查询。<br/>
在写入慢查询日志的语句中包含慢速管理语句。包括ALTER TABLE， ANALYZE TABLE， CHECK TABLE， CREATE INDEX， DROP INDEX， OPTIMIZE TABLE，和REPAIR TABLE</p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">log_queries_not_using_indexes</strong><br/>
默认情况下，不记录管理语句，也不记录不使用索引进行查找的查询。<br/>
是否将不使用索引的查询记录到慢查询日志中</p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">log_throttle_queries_not_using_indexes</strong><br/>
如果 log_queries_not_using_indexes 启用，慢查询日志可能会快速增长，则 log_throttle_queries_not_using_indexes 变量限制可以写入慢查询日志的每分钟此类查询的数量。值0（默认值）表示“ 无限制 ”。</p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">--log_short_format选项</strong><br/>
服务器会将较少的信息写入慢查询日志。</p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">log_output</strong><br/>
一般查询日志和慢查询日志输出的目标或目标。该值是一个列表选自一个或多个以逗号分隔的话TABLE， FILE和NONE；<br/>
<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">TABLE</strong>选择记录到系统数据库mysql中的 general_log和slow_log表；<br/>
<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">FILE</strong>选择记录到日志文件；<br/>
<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">NONE</strong>禁用日志记录；<br/>
如果 NONE值存在，则它优先于存在的任何其他单词。 TABLE并且FILE可以同时选择两个日志输出目的地。<br/>
此变量选择日志输出目标，但不启用日志输出。为此，请启用 general_log和 slow_query_log系统变量。对于FILE日志记录， 系统变量general_log_file和slow_query_log_file系统变量确定日志文件位置。</p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">log_slow_slave_statements</strong><br/>
默认情况下，复制从属服务器不会将复制查询写入慢速查询日志。要更改此设置，请启用 log_slow_slave_statements 系统变量。</p>
</li>
</ul>
<h2 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 34px; border-bottom: 1px solid #dbdbdb; color: #333;">慢查询日志内容</h2>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">启用慢查询日志时，服务器将输出写入<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">log_output</strong>系统变量指定的任何目标 。如果启用日志，则服务器将打开日志文件并将启动消息写入其中。但是，除非FILE选择了日志目标，否则不会进一步将查询记录到文件中。如果目标是 NONE，则即使启用了慢查询日志，服务器也不会写入任何查询。如果FILE未选择作为输出目标，则设置日志文件名对日志记录没有影响。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">如果启用慢查询日志并将FILE其选为输出目标，则写入日志的每个语句前面都有一个以#字符开头 并且包含这些字段的行（所有字段都在一行中）：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">Query_time</strong>：语句执行的持续时间（以秒为单位）；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">Lock_time</strong>：语句获取锁的时间（以秒为单位）；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">Rows_sent</strong>：语句发送到客户端的记录行数；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">Rows_examined</strong>：优化程序检查的行数；</li>
</ul>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">写入慢查询日志文件的每个语句前面都有一个SET 语句，该语句包含一个时间戳，指示何时记录慢语句（在语句完成执行后发生）。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">写入慢查询日志的语句中的密码将由服务器重写，而不是以纯文本形式发生。详见：https://dev.mysql.com/doc/refman/5.7/en/password-logging.html</p>
<h2 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 34px; border-bottom: 1px solid #dbdbdb; color: #333;">mysqldumpslow-慢查询日志文件汇总</h2>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">MySQL慢查询日志包含有关需要很长时间才能执行的查询的信息（请参见 第5.4.5节“慢查询日志”）。 mysqldumpslow解析MySQL慢查询日志文件并总结其内容。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">通常，除了数字和字符串数据值的特定值之外，mysqldumpslow对类似的查询进行分组。它将这些值“ 抽象 ”为 N和'S'显示摘要输出。要修改值抽象行为，请使用 -a和-n选项。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">像这样 调用mysqldumpslow：<br/>
<img src="27-慢查询日志_files/Image.png" type="image/png" data-filename="Image.png"/></p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">mysqldumpslow支持以下选项：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;">--help：显示帮助信息并退出；</p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;">-a：不要将所有数字和字符串抽象为N和'S'；</p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;">-d：在调试模式下运行；</p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;">-g <em style="line-height: 160%; box-sizing: content-box; font-style: italic;">pattern</em>：仅考虑与（grep- style）模式匹配的查询；</p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;">-h <em style="line-height: 160%; box-sizing: content-box; font-style: italic;">host_name</em>：* -slow.log文件名 的MySQL服务器的主机 名。该值可以包含通配符。默认值为* （全部匹配）；</p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;">-i <em style="line-height: 160%; box-sizing: content-box; font-style: italic;">name</em>：服务器实例的名称（如果使用 mysql.server启动脚本）；</p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;">-l：不从总时间中减去锁定时间；</p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;">-n <em style="line-height: 160%; box-sizing: content-box; font-style: italic;">N</em>：N 名称 中至少有数字的抽象数字；</p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;">-r：反转排序顺序；</p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;">-s <em style="line-height: 160%; box-sizing: content-box; font-style: italic;">sort_type</em>：<br/>
如何对输出进行排序。sort_type应从以下列表中选择值 ：<img src="27-慢查询日志_files/Image [1].png" type="image/png" data-filename="Image.png"/></p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;">-t <em style="line-height: 160%; box-sizing: content-box; font-style: italic;">N</em>：仅显示N输出中的第一个查询；</p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;">--verbose，-v：详细模式。打印有关程序功能的更多信息。</p>
</li>
</ul>
</div><center style="display:none !important;visibility:collapse !important;height:0 !important;white-space:nowrap;width:100%;overflow:hidden">%23%23%20%0A%E6%85%A2%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E7%94%B1%E6%89%A7%E8%A1%8C%E6%97%B6%E9%97%B4%E8%B6%85%E8%BF%87**long_query_time**%EF%BC%8C%E5%B9%B6%E4%B8%94%E6%89%AB%E9%9D%A2%E8%AE%B0%E5%BD%95%E8%A1%8C%E6%95%B0%E5%A4%A7%E4%BA%8E%E7%AD%89%E4%BA%8E**min_examined_row_limit**%E7%9A%84SQL%E8%AF%AD%E5%8F%A5%E7%BB%84%E6%88%90%E3%80%82%0A%0A%E6%85%A2%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E5%8F%AF%E7%94%A8%E4%BA%8E%E6%9F%A5%E6%89%BE%E9%9C%80%E8%A6%81%E5%BE%88%E9%95%BF%E6%97%B6%E9%97%B4%E6%89%8D%E8%83%BD%E6%89%A7%E8%A1%8C%E7%9A%84%E6%9F%A5%E8%AF%A2%EF%BC%8C%E5%9B%A0%E6%AD%A4%E6%98%AF%E4%BC%98%E5%8C%96%E7%9A%84%E5%80%99%E9%80%89%E8%80%85%E3%80%82%E4%BD%86%E6%98%AF%EF%BC%8C%E6%A3%80%E6%9F%A5%E6%85%A2%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E5%8F%AF%E8%83%BD%E6%98%AF%E4%B8%80%E9%A1%B9%E8%80%97%E6%97%B6%E7%9A%84%E4%BB%BB%E5%8A%A1%E3%80%82%E4%B8%BA%E4%BA%86%E7%AE%80%E5%8C%96%E8%BF%99%E4%B8%80%E8%BF%87%E7%A8%8B%EF%BC%8C%E5%8F%AF%E4%BB%A5%E4%BD%BF%E7%94%A8**mysqldumpslow**%E5%91%BD%E4%BB%A4%E5%A4%84%E7%90%86%E6%85%A2%E9%80%9F%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E6%96%87%E4%BB%B6%E5%B9%B6%E6%B1%87%E6%80%BB%E5%85%B6%E5%86%85%E5%AE%B9%E3%80%82%0A%0A%E8%8E%B7%E5%8F%96%E5%88%9D%E5%A7%8B%E9%94%81%E5%AE%9A%E7%9A%84%E6%97%B6%E9%97%B4%E4%B8%8D%E8%AE%A1%E5%85%A5%E6%89%A7%E8%A1%8C%E6%97%B6%E9%97%B4%E3%80%82mysqld%E5%9C%A8%E6%89%A7%E8%A1%8C%E5%AE%8C%E5%90%8E%E4%BB%A5%E5%8F%8A%E9%87%8A%E6%94%BE%E6%89%80%E6%9C%89%E9%94%81%E4%B9%8B%E5%90%8E%E5%90%91%E6%85%A2%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E5%86%99%E5%85%A5%E4%B8%80%E4%B8%AA%E8%AF%AD%E5%8F%A5%EF%BC%8C%E5%9B%A0%E6%AD%A4%E6%97%A5%E5%BF%97%E9%A1%BA%E5%BA%8F%E5%8F%AF%E8%83%BD%E4%B8%8E%E6%89%A7%E8%A1%8C%E9%A1%BA%E5%BA%8F%E4%B8%8D%E5%90%8C%E3%80%82%0A%0A%23%23%20%E6%85%A2%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E5%8F%82%E6%95%B0%0A%0A*%20**slow_query_log**%0A%E9%BB%98%E8%AE%A4%E6%83%85%E5%86%B5%E4%B8%8B%EF%BC%8C%E7%A6%81%E7%94%A8%E6%85%A2%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E3%80%82%E8%A6%81%E6%98%8E%E7%A1%AE%E6%8C%87%E5%AE%9A%E5%88%9D%E5%A7%8B%E6%85%A2%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E7%8A%B6%E6%80%81%EF%BC%8C0%E5%85%B3%E9%97%AD%EF%BC%8C1%E5%BC%80%E5%90%AF%E3%80%82%E8%A6%81%E6%8C%87%E5%AE%9A%E6%97%A5%E5%BF%97%E6%96%87%E4%BB%B6%E5%90%8D%EF%BC%8C%E4%BD%BF%E7%94%A8**slow_query_log_file**%EF%BC%8C%E8%A6%81%E6%8C%87%E5%AE%9A%E6%97%A5%E5%BF%97%E7%9B%AE%E6%A0%87%EF%BC%8C%E4%BD%BF%E7%94%A8**log_output**%0A%0A*%20**slow_query_log_file**%0A%E5%A6%82%E6%9E%9C%E6%B2%A1%E6%9C%89%E4%B8%BA%E6%85%A2%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E6%96%87%E4%BB%B6%E6%8C%87%E5%AE%9A%E5%90%8D%E7%A7%B0%EF%BC%8C%E5%88%99%E9%BB%98%E8%AE%A4%E5%90%8D%E7%A7%B0%E4%B8%BA%C2%A0host_name-slow.log%E3%80%82%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%9C%A8%E6%95%B0%E6%8D%AE%E7%9B%AE%E5%BD%95%E4%B8%AD%E5%88%9B%E5%BB%BA%E6%96%87%E4%BB%B6%EF%BC%8C%E9%99%A4%E9%9D%9E%E7%BB%99%E5%87%BA%E7%BB%9D%E5%AF%B9%E8%B7%AF%E5%BE%84%E5%90%8D%E6%9D%A5%E6%8C%87%E5%AE%9A%E4%B8%8D%E5%90%8C%E7%9A%84%E7%9B%AE%E5%BD%95%E3%80%82%0A%0A*%20**long_query_time**%0A%E6%9C%80%E5%B0%8F%E5%80%BC%E4%B8%BA0%EF%BC%8C%E9%BB%98%E8%AE%A4%E5%80%BC%E4%B8%BA10%EF%BC%8C%E5%8D%95%E4%BD%8D%E7%A7%92%EF%BC%8C%E8%8C%83%E5%9B%B4%EF%BC%9Aglobal%E3%80%81session%0A%0A*%20**log_slow_admin_statements**%0A%E9%BB%98%E8%AE%A4%E6%83%85%E5%86%B5%E4%B8%8B%EF%BC%8C%E4%B8%8D%E8%AE%B0%E5%BD%95%E7%AE%A1%E7%90%86%E8%AF%AD%E5%8F%A5%EF%BC%8C%E4%B9%9F%E4%B8%8D%E8%AE%B0%E5%BD%95%E4%B8%8D%E4%BD%BF%E7%94%A8%E7%B4%A2%E5%BC%95%E8%BF%9B%E8%A1%8C%E6%9F%A5%E6%89%BE%E7%9A%84%E6%9F%A5%E8%AF%A2%E3%80%82%0A%E5%9C%A8%E5%86%99%E5%85%A5%E6%85%A2%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E7%9A%84%E8%AF%AD%E5%8F%A5%E4%B8%AD%E5%8C%85%E5%90%AB%E6%85%A2%E9%80%9F%E7%AE%A1%E7%90%86%E8%AF%AD%E5%8F%A5%E3%80%82%E5%8C%85%E6%8B%ACALTER%20TABLE%EF%BC%8C%C2%A0ANALYZE%20TABLE%EF%BC%8C%C2%A0CHECK%20TABLE%EF%BC%8C%C2%A0CREATE%20INDEX%EF%BC%8C%C2%A0DROP%20INDEX%EF%BC%8C%C2%A0OPTIMIZE%20TABLE%EF%BC%8C%E5%92%8CREPAIR%20TABLE%0A%0A*%20**log_queries_not_using_indexes**%0A%E9%BB%98%E8%AE%A4%E6%83%85%E5%86%B5%E4%B8%8B%EF%BC%8C%E4%B8%8D%E8%AE%B0%E5%BD%95%E7%AE%A1%E7%90%86%E8%AF%AD%E5%8F%A5%EF%BC%8C%E4%B9%9F%E4%B8%8D%E8%AE%B0%E5%BD%95%E4%B8%8D%E4%BD%BF%E7%94%A8%E7%B4%A2%E5%BC%95%E8%BF%9B%E8%A1%8C%E6%9F%A5%E6%89%BE%E7%9A%84%E6%9F%A5%E8%AF%A2%E3%80%82%0A%E6%98%AF%E5%90%A6%E5%B0%86%E4%B8%8D%E4%BD%BF%E7%94%A8%E7%B4%A2%E5%BC%95%E7%9A%84%E6%9F%A5%E8%AF%A2%E8%AE%B0%E5%BD%95%E5%88%B0%E6%85%A2%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E4%B8%AD%0A%0A*%20**log_throttle_queries_not_using_indexes**%0A%E5%A6%82%E6%9E%9C%C2%A0log_queries_not_using_indexes%C2%A0%E5%90%AF%E7%94%A8%EF%BC%8C%E6%85%A2%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E5%8F%AF%E8%83%BD%E4%BC%9A%E5%BF%AB%E9%80%9F%E5%A2%9E%E9%95%BF%EF%BC%8C%E5%88%99%C2%A0log_throttle_queries_not_using_indexes%C2%A0%E5%8F%98%E9%87%8F%E9%99%90%E5%88%B6%E5%8F%AF%E4%BB%A5%E5%86%99%E5%85%A5%E6%85%A2%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E7%9A%84%E6%AF%8F%E5%88%86%E9%92%9F%E6%AD%A4%E7%B1%BB%E6%9F%A5%E8%AF%A2%E7%9A%84%E6%95%B0%E9%87%8F%E3%80%82%E5%80%BC0%EF%BC%88%E9%BB%98%E8%AE%A4%E5%80%BC%EF%BC%89%E8%A1%A8%E7%A4%BA%E2%80%9C%C2%A0%E6%97%A0%E9%99%90%E5%88%B6%C2%A0%E2%80%9D%E3%80%82%0A%0A*%20**--log_short_format%E9%80%89%E9%A1%B9**%0A%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%BC%9A%E5%B0%86%E8%BE%83%E5%B0%91%E7%9A%84%E4%BF%A1%E6%81%AF%E5%86%99%E5%85%A5%E6%85%A2%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E3%80%82%0A%0A*%20**log_output**%0A%E4%B8%80%E8%88%AC%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E5%92%8C%E6%85%A2%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E8%BE%93%E5%87%BA%E7%9A%84%E7%9B%AE%E6%A0%87%E6%88%96%E7%9B%AE%E6%A0%87%E3%80%82%E8%AF%A5%E5%80%BC%E6%98%AF%E4%B8%80%E4%B8%AA%E5%88%97%E8%A1%A8%E9%80%89%E8%87%AA%E4%B8%80%E4%B8%AA%E6%88%96%E5%A4%9A%E4%B8%AA%E4%BB%A5%E9%80%97%E5%8F%B7%E5%88%86%E9%9A%94%E7%9A%84%E8%AF%9DTABLE%EF%BC%8C%C2%A0FILE%E5%92%8CNONE%EF%BC%9B%0A**TABLE**%E9%80%89%E6%8B%A9%E8%AE%B0%E5%BD%95%E5%88%B0%E7%B3%BB%E7%BB%9F%E6%95%B0%E6%8D%AE%E5%BA%93mysql%E4%B8%AD%E7%9A%84%C2%A0general_log%E5%92%8Cslow_log%E8%A1%A8%EF%BC%9B%0A**FILE**%E9%80%89%E6%8B%A9%E8%AE%B0%E5%BD%95%E5%88%B0%E6%97%A5%E5%BF%97%E6%96%87%E4%BB%B6%EF%BC%9B%0A**NONE**%E7%A6%81%E7%94%A8%E6%97%A5%E5%BF%97%E8%AE%B0%E5%BD%95%EF%BC%9B%0A%E5%A6%82%E6%9E%9C%C2%A0NONE%E5%80%BC%E5%AD%98%E5%9C%A8%EF%BC%8C%E5%88%99%E5%AE%83%E4%BC%98%E5%85%88%E4%BA%8E%E5%AD%98%E5%9C%A8%E7%9A%84%E4%BB%BB%E4%BD%95%E5%85%B6%E4%BB%96%E5%8D%95%E8%AF%8D%E3%80%82%C2%A0TABLE%E5%B9%B6%E4%B8%94FILE%E5%8F%AF%E4%BB%A5%E5%90%8C%E6%97%B6%E9%80%89%E6%8B%A9%E4%B8%A4%E4%B8%AA%E6%97%A5%E5%BF%97%E8%BE%93%E5%87%BA%E7%9B%AE%E7%9A%84%E5%9C%B0%E3%80%82%0A%E6%AD%A4%E5%8F%98%E9%87%8F%E9%80%89%E6%8B%A9%E6%97%A5%E5%BF%97%E8%BE%93%E5%87%BA%E7%9B%AE%E6%A0%87%EF%BC%8C%E4%BD%86%E4%B8%8D%E5%90%AF%E7%94%A8%E6%97%A5%E5%BF%97%E8%BE%93%E5%87%BA%E3%80%82%E4%B8%BA%E6%AD%A4%EF%BC%8C%E8%AF%B7%E5%90%AF%E7%94%A8%C2%A0general_log%E5%92%8C%C2%A0slow_query_log%E7%B3%BB%E7%BB%9F%E5%8F%98%E9%87%8F%E3%80%82%E5%AF%B9%E4%BA%8EFILE%E6%97%A5%E5%BF%97%E8%AE%B0%E5%BD%95%EF%BC%8C%C2%A0%E7%B3%BB%E7%BB%9F%E5%8F%98%E9%87%8Fgeneral_log_file%E5%92%8Cslow_query_log_file%E7%B3%BB%E7%BB%9F%E5%8F%98%E9%87%8F%E7%A1%AE%E5%AE%9A%E6%97%A5%E5%BF%97%E6%96%87%E4%BB%B6%E4%BD%8D%E7%BD%AE%E3%80%82%0A%0A*%20**log_slow_slave_statements**%0A%E9%BB%98%E8%AE%A4%E6%83%85%E5%86%B5%E4%B8%8B%EF%BC%8C%E5%A4%8D%E5%88%B6%E4%BB%8E%E5%B1%9E%E6%9C%8D%E5%8A%A1%E5%99%A8%E4%B8%8D%E4%BC%9A%E5%B0%86%E5%A4%8D%E5%88%B6%E6%9F%A5%E8%AF%A2%E5%86%99%E5%85%A5%E6%85%A2%E9%80%9F%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E3%80%82%E8%A6%81%E6%9B%B4%E6%94%B9%E6%AD%A4%E8%AE%BE%E7%BD%AE%EF%BC%8C%E8%AF%B7%E5%90%AF%E7%94%A8%C2%A0log_slow_slave_statements%C2%A0%E7%B3%BB%E7%BB%9F%E5%8F%98%E9%87%8F%E3%80%82%0A%0A%0A%0A%0A%0A%23%23%20%E6%85%A2%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E5%86%85%E5%AE%B9%0A%0A%E5%90%AF%E7%94%A8%E6%85%A2%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E6%97%B6%EF%BC%8C%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%B0%86%E8%BE%93%E5%87%BA%E5%86%99%E5%85%A5**log_output**%E7%B3%BB%E7%BB%9F%E5%8F%98%E9%87%8F%E6%8C%87%E5%AE%9A%E7%9A%84%E4%BB%BB%E4%BD%95%E7%9B%AE%E6%A0%87%C2%A0%E3%80%82%E5%A6%82%E6%9E%9C%E5%90%AF%E7%94%A8%E6%97%A5%E5%BF%97%EF%BC%8C%E5%88%99%E6%9C%8D%E5%8A%A1%E5%99%A8%E5%B0%86%E6%89%93%E5%BC%80%E6%97%A5%E5%BF%97%E6%96%87%E4%BB%B6%E5%B9%B6%E5%B0%86%E5%90%AF%E5%8A%A8%E6%B6%88%E6%81%AF%E5%86%99%E5%85%A5%E5%85%B6%E4%B8%AD%E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%89%E4%B8%80%E4%B8%AASET%C2%A0%E8%AF%AD%E5%8F%A5%EF%BC%8C%E8%AF%A5%E8%AF%AD%E5%8F%A5%E5%8C%85%E5%90%AB%E4%B8%80%E4%B8%AA%E6%97%B6%E9%97%B4%E6%88%B3%EF%BC%8C%E6%8C%87%E7%A4%BA%E4%BD%95%E6%97%B6%E8%AE%B0%E5%BD%95%E6%85%A2%E8%AF%AD%E5%8F%A5%EF%BC%88%E5%9C%A8%E8%AF%AD%E5%8F%A5%E5%AE%8C%E6%88%90%E6%89%A7%E8%A1%8C%E5%90%8E%E5%8F%91%E7%94%9F%EF%BC%89%E3%80%82%0A%0A%0A%E5%86%99%E5%85%A5%E6%85%A2%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E7%9A%84%E8%AF%AD%E5%8F%A5%E4%B8%AD%E7%9A%84%E5%AF%86%E7%A0%81%E5%B0%86%E7%94%B1%E6%9C%8D%E5%8A%A1%E5%99%A8%E9%87%8D%E5%86%99%EF%BC%8C%E8%80%8C%E4%B8%8D%E6%98%AF%E4%BB%A5%E7%BA%AF%E6%96%87%E6%9C%AC%E5%BD%A2%E5%BC%8F%E5%8F%91%E7%94%9F%E3%80%82%E8%AF%A6%E8%A7%81%EF%BC%9Ahttps%3A%2F%2Fdev.mysql.com%2Fdoc%2Frefman%2F5.7%2Fen%2Fpassword-logging.html%0A%0A%0A%23%23%20mysqldumpslow-%E6%85%A2%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E6%96%87%E4%BB%B6%E6%B1%87%E6%80%BB%0A%0AMySQL%E6%85%A2%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E5%8C%85%E5%90%AB%E6%9C%89%E5%85%B3%E9%9C%80%E8%A6%81%E5%BE%88%E9%95%BF%E6%97%B6%E9%97%B4%E6%89%8D%E8%83%BD%E6%89%A7%E8%A1%8C%E7%9A%84%E6%9F%A5%E8%AF%A2%E7%9A%84%E4%BF%A1%E6%81%AF%EF%BC%88%E8%AF%B7%E5%8F%82%E8%A7%81%C2%A0%E7%AC%AC5.4.5%E8%8A%82%E2%80%9C%E6%85%A2%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E2%80%9D%EF%BC%89%E3%80%82%C2%A0mysqldumpslow%E8%A7%A3%E6%9E%90MySQL%E6%85%A2%E6%9F%A5%E8%AF%A2%E6%97%A5%E5%BF%97%E6%96%87%E4%BB%B6%E5%B9%B6%E6%80%BB%E7%BB%93%E5%85%B6%E5%86%85%E5%AE%B9%E3%80%82%0A%0A%E9%80%9A%E5%B8%B8%EF%BC%8C%E9%99%A4%E4%BA%86%E6%95%B0%E5%AD%97%E5%92%8C%E5%AD%97%E7%AC%A6%E4%B8%B2%E6%95%B0%E6%8D%AE%E5%80%BC%E7%9A%84%E7%89%B9%E5%AE%9A%E5%80%BC%E4%B9%8B%E5%A4%96%EF%BC%8Cmysqldumpslow%E5%AF%B9%E7%B1%BB%E4%BC%BC%E7%9A%84%E6%9F%A5%E8%AF%A2%E8%BF%9B%E8%A1%8C%E5%88%86%E7%BB%84%E3%80%82%E5%AE%83%E5%B0%86%E8%BF%99%E4%BA%9B%E5%80%BC%E2%80%9C%C2%A0%E6%8A%BD%E8%B1%A1%C2%A0%E2%80%9D%E4%B8%BA%C2%A0N%E5%92%8C'S'%E6%98%BE%E7%A4%BA%E6%91%98%E8%A6%81%E8%BE%93%E5%87%BA%E3%80%82%E8%A6%81%E4%BF%AE%E6%94%B9%E5%80%BC%E6%8A%BD%E8%B1%A1%E8%A1%8C%E4%B8%BA%EF%BC%8C%E8%AF%B7%E4%BD%BF%E7%94%A8%C2%A0-a%E5%92%8C-n%E9%80%89%E9%A1%B9%E3%80%82%0A%0A%0A%E5%83%8F%E8%BF%99%E6%A0%B7%C2%A0%E8%B0%83%E7%94%A8mysqldumpslow%EF%BC%9A%0A!%5B65704a77b4c5b0f7326b6af9f17520f3.png%5D(en-resource%3A%2F%2Fdatabase%2F1303%3A0)%0A%0A%0A%0Am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BF%E7%94%A8%C2%A0mysql.server%E5%90%AF%E5%8A%A8%E8%84%9A%E6%9C%AC%EF%BC%89%EF%BC%9B%0A*%20-l%EF%BC%9A%E4%B8%8D%E4%BB%8E%E6%80%BB%E6%97%B6%E9%97%B4%E4%B8%AD%E5%87%8F%E5%8E%BB%E9%94%81%E5%AE%9A%E6%97%B6%E9%97%B4%EF%BC%9B%0A*%20-n%20*N*%EF%BC%9AN%C2%A0%E5%90%8D%E7%A7%B0%C2%A0%E4%B8%AD%E8%87%B3%E5%B0%91%E6%9C%89%E6%95%B0%E5%AD%97%E7%9A%84%E6%8A%BD%E8%B1%A1%E6%95%B0%E5%AD%97%EF%BC%9B%0A*%20-r%EF%BC%9A%E5%8F%8D%E8%BD%AC%E6%8E%92%E5%BA%8F%E9%A1%BA%E5%BA%8F%EF%BC%9B%0A*%20-s%20*sort_type*%EF%BC%9A%0A%E5%A6%82%E4%BD%95%E5%AF%B9%E8%BE%93%E5%87%BA%E8%BF%9B%E8%A1%8C%E6%8E%92%E5%BA%8F%E3%80%82sort_type%E5%BA%94%E4%BB%8E%E4%BB%A5%E4%B8%8B%E5%88%97%E8%A1%A8%E4%B8%AD%E9%80%89%E6%8B%A9%E5%80%BC%C2%A0%EF%BC%9A!%5B6b412954fe627569697125a87660773b.png%5D(en-resource%3A%2F%2Fdatabase%2F1305%3A0)%0A%0A*%20-t%C2%A0*N*%EF%BC%9A%E4%BB%85%E6%98%BE%E7%A4%BAN%E8%BE%93%E5%87%BA%E4%B8%AD%E7%9A%84%E7%AC%AC%E4%B8%80%E4%B8%AA%E6%9F%A5%E8%AF%A2%EF%BC%9B%0A*%20--verbose%EF%BC%8C-v%EF%BC%9A%E8%AF%A6%E7%BB%86%E6%A8%A1%E5%BC%8F%E3%80%82%E6%89%93%E5%8D%B0%E6%9C%89%E5%85%B3%E7%A8%8B%E5%BA%8F%E5%8A%9F%E8%83%BD%E7%9A%84%E6%9B%B4%E5%A4%9A%E4%BF%A1%E6%81%AF%E3%80%82</center></span>
</div></body></html> 